from twisted.internet import protocol, reactor
from twisted.protocols import basic
class ChatProtocol(basic.LineReceiver):
	def lineReceived(self, message):
		username, msg = message.split(':')
		self.factory.got_chat_message(username, msg)
		self.transport.loseConnection()
class ChatFactory(protocol.ServerFactory):
	protocol = ChatProtocol
	def got_chat_message(self, user, message):
		print 'Chat message from: ' + user + ' with the message: ' + message
reactor.listenTCP(1079, ChatFactory())
reactor.run()